<template>
  <div class="main_box" style="padding:10px">
    <div class="add_wrap">
      <el-form label-width="200px" v-if="dataInfo">
        <div class="tit">
          <h2>基础信息</h2>
          <el-button type="success" plain size="small" icon="fa fa-mail-forward" @click="returnList">返回</el-button>
        </div>
        <el-row>
          <el-form-item label="管理员编号:">
            <span>{{ dataInfo.userCode }}</span>
          </el-form-item>
          <el-form-item label="管理员类型:">
            <span>{{ formatManagerLevels(dataInfo.managerLevels) }}</span>
          </el-form-item>
          <el-form-item label="用户名:">
            <span>{{ dataInfo.userName }}</span>
          </el-form-item>
          <el-form-item label="昵称:">
            <span>{{ dataInfo.nickName }}</span>
          </el-form-item>
          <el-form-item label="姓名:">
            <span>{{ dataInfo.fullName }}</span>
          </el-form-item>
          <el-form-item label="性别:">
            <span>{{dataInfo.sex==1?'男':'女'}}</span>
          </el-form-item>
          <el-form-item label="电话号码:">
            <span>{{ dataInfo.phone }}</span>
          </el-form-item>
          <el-form-item label="部门:">
            <span>{{ departNames }}</span>
          </el-form-item>
          <el-form-item label="备注:">
            <span>{{ dataInfo.remark }}</span>
          </el-form-item>
          <el-form-item label="创建人:">
            <span>{{ dataInfo.createUserName }}</span>
          </el-form-item>
          <el-form-item label="创建时间:">
            <span>{{ dataInfo.createDate }}</span>
          </el-form-item>
          <el-form-item label="修改人:">
            <span>{{ dataInfo.modifyUserName }}</span>
          </el-form-item>
          <el-form-item label="修改时间:">
            <span>{{ dataInfo.modifyDate }}</span>
          </el-form-item>
        </el-row>
      </el-form>
    </div>
  </div>
</template>

  <script>
  import ManagerBusinessApi from "@/api/business/manager";
  import BusinessDepartApi from "@/api/business/depart"
  export default{
      data(){
          return {
            dataInfo: {},
            departNames:""
          }
      },
      mounted(){
        this.init();
      },
      methods:{
        init(){
          this.getData();
        },
        getData(){
          ManagerBusinessApi.getManagerInfo({id:this.$route.query.id}).then(res=>{
            this.dataInfo = res.data;
            this.getDepartList()
          })
        },
        getDepartList(){
            BusinessDepartApi.listMangerTree().then(res=>{
              this.departList = res.data
              this.getDepartNames()
            })
        },
        getDepartNames(){
          const departNames = []
            if(!this.dataInfo.departIds)return
            this.dataInfo.departIds.forEach(item=>{
              const val = this.$Utils.filterTreeToArr(this.departList,{departId:item},'departId').at(-1).departName
              departNames.push(val)
            })
          this.departNames = departNames.toString()
        },
        /**
         * 过滤器
         */
        formatManagerLevels(value){
          if(value == 0){
            return "商户";
          }else if(value== 1){
            return "部门";
          }else if(value== 2){
            return "组";
          }else if(value==3){
            return "岗位"
          }
        },
        returnList(){
          this.$store.dispatch('delView', this.$route);
          this.$router.back()
        }
      },
  }
  </script>
<style lang="scss" scoped>
@import "@/assets/css/views/add.scss";
</style>
